#!/bin/sh
TMP=/var/log/setup/tmp
if [ ! -d $TMP ]; then
  mkdir -p $TMP
fi
T_PX="`cat $TMP/SeTT_PX`"
while [ "`cat $T_PX/etc/shadow | fgrep 'root:' | cut -f 2 -d :`" = "" ]; do
  # There is no root password
  dialog --title "WARNING: NO ROOT PASSWORD DETECTED" --yesno "There is \
currently no password set on the system administrator account (root).  \
It is recommended that you set one now so that it is active the first \
time the machine is rebooted.  This is especially important if you're \
using a network enabled kernel and the machine is on an Internet \
connected LAN.  Would you like to set a root password?" 10 68
  if [ $? = 0 ] ; then
    echo
    echo
    echo
    chroot $T_PX /usr/bin/passwd root
    echo
    echo -n "Press [enter] to continue:"
    read junk;
    echo
    # Here we drop through, and if there's still no password the menu
    # runs again.
  else
    # Don't set a password:
    break;
  fi
done

# Add new user
dialog --title "ADD NEW USER" --inputbox \
"It's recommended that you create a normal user for day to day use. \
If you need root access use 'su -' or sudo (third-party). \
Please enter username:" \
10 64 2> $TMP/SeTUSER
if [ ! $? = 0 ]; then
  rm -f $TMP/SeTUSER
  exit
fi
NEWUSER="`cat $TMP/SeTUSER`"
if [ "$NEWUSER" ]; then
  chroot $T_PX /usr/sbin/useradd -g users -G wheel,cdrom,plugdev,audio,video -d /home/$NEWUSER -m -s /bin/bash $NEWUSER
  if [ "`cat $T_PX/etc/shadow | fgrep '${NEWUSER}:' | cut -f 2 -d :`" = "" ]; then
    chroot $T_PX /usr/bin/passwd $NEWUSER
    echo
    echo -n "Press [enter] to continue:"
    read junk;
    echo
  fi
  rm -f $TMP/SeTUSER
fi

